home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-07
/
lanbook.zip
/
NOSIF.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-09-22
|
6KB
|
220 lines
;
; NOSIF.ASM
;
; (c) 1991 Adrian J.King
;
; This code was developed for inclusion in the book
; "Running LANtastic", by Adrian King, published by
; Bantam Books, October 1991.
;
; This module includes the C to assembler interface routines needed
; to interface correctly between the NOS and the LANRES program.
;
; $Header: C:/USR/LANBOOK/SRC2/LAN/VCS/NOSIF.ASV 1.1 22 Sep 1991 8:22:40 $
;
; $Log: C:/USR/LANBOOK/SRC2/LAN/VCS/NOSIF.ASV $
;
; Rev 1.1 22 Sep 1991 8:22:40
;Moved entercrit() and leavecrit() into this module.
;Cosmetic touch ups.
;
; Rev 1.0 13 Jul 1991 11:20:24
;Initial revision.
;
.model small,C
.data
EXTRN oldservice:FAR ; Address of old msg service vector
EXTRN olddos:FAR ; Address of old DOS vector
PUBLIC bworktodo
bworktodo dw 0 ; Non-zero when there is work to do
bcalled dw 0 ; Non-zero when dowork() already called
.code
PUBLIC msg_interrupt ; Entered from LANOS when msg received
PUBLIC nos_interrupt ; Called by LANOS when DOS can be called
PUBLIC nowhere ; Null routine used as target for
; call to old message service until
; the proper target has been setup
PUBLIC entercrit ; Enter a critical region
PUBLIC leavecrit ; Leave a critical region
EXTRN msg_proc:FAR ; New message service processor
EXTRN dowork:FAR ; NOS idle time processor
msg_interrupt PROC FAR
; This routine is used as the target for the SET MESSAGE SERVICE
; call to NOS. It calls the msg_proc routine in the lanres.c module.
;
; Entry: ES:BX points to message
; All other registers unknown but will be saved
;
; Processing: Call the old message service vector (retrieved by the
; GET MESSAGE SERVICE call to NOS).
;
; Call the msg_proc routine with the message pointer
;
; Exit: All registers restored to their values on entry.
;
assume ds:NOTHING
cli
push ax
push ds
mov ax,DGROUP ; Set up C runtime DS
mov ds,ax
assume ds:DGROUP
; Save everything except flags, which
; will be restored via IRET
push si
push di
push bp
push cx
push dx
push es ; ES:BX will be parameter to msg_proc()
push bx
push ds ; Save DS through next call
pushf ; Old service returns via IRET,
; so simulate an INT by pushing flags
; and making a far call.
call dword ptr oldservice ; Call old message service
pop ds
call msg_proc ; Call our message service
pop bx ; Restore everything
pop es
pop dx
pop cx
pop bp
pop di
pop si
pop ds
pop ax
sti
iret ; We were called via an INT, so we IRET
msg_interrupt ENDP
nos_interrupt PROC FAR
; This routine is used as the target for the DOS SERVICE VECTOR
; call to NOS. It calls the dowork() routine in the lanlib.c module.
;
; Entry: All registers unknown but will be saved
;
; Processing: Call the old DOS service vector (retrieved by the
; GET SERVICE VECTOR call to NOS).
;
; Call the dowork() routine.
;
; Exit: All registers restored to their values on entry.
;
assume ds:NOTHING
cli
push ax ; Save AX
push ds
mov ax,DGROUP ; Set up C runtime DS
mov ds,ax
assume ds:DGROUP
dos_main:
mov ax,bcalled ; Check re-entrancy
jnz no_call ; Already running, leave
mov ax,bworktodo ; Only call when there is work to do
or ax,ax
jnz dos_call ; Yes, go process work request
no_call:
pop ds ; No work. Leave.
pop ax
sti
iret
dos_call:
mov bcalled,ax ; Set lock so dowork() only gets
; called once
sti
; Save everything except flags, which
; will be restored via IRET
push si
push di
push bp
push cx
push dx
push es
push bx
push ds ; Save DS through next call
pushf ; Old service returns via IRET,
; so simulate an INT by pushing flags
; and making a far call.
call dword ptr olddos ; Call old DOS service
pop ds
call dowork ; Call our DOS service routine
pop bx ; Restore everything
pop es
pop dx
pop cx
pop bp
pop di
pop si
cli ; Clear called flag carefully
xor ax,ax
mov bcalled,ax
pop ds
pop ax
sti
iret ; We were called via an INT, so we IRET
nos_interrupt ENDP
nowhere PROC FAR
; This routine does nothing. It is used as a target for the call to
; the old message service in case the old message service address is
; not properly setup. (I.e. it avoids a jump into hyperspace.)
; This could be a C interrupt procedure with a null body.
iret ; Just return, as if from an INT
nowhere ENDP
;
; Enter and leave a critical region. Called by LANRES when fiddling
; with global data structures.
;
entercrit PROC FAR
cli
ret
entercrit ENDP
leavecrit PROC FAR
sti
ret
leavecrit ENDP
END